/**
 * 手写柯里化，递归收集参数，args 在闭包中可以一直引用
*/

const curry = (fn, ...args) => {
  return args.length >= fn.length ? fn(...args) : (..._args) => curry(fn, ...args, ..._args)
}

const add = (x, y, z) => x + y + z
const curryAdd = curry(add)

// console.log(curryAdd)
console.log(curryAdd(1)(2)(3))

